package scaladuct

import asm.{Scala2JavaBeanClassWriter}
import l10n.{HasHintsMetaDataSourceProvider, HasHintsMetaData, HasHintsMetaDataSource}
import java.util.Locale
import l10n.{DefaultCommonMetaData, ConfigPageMetaData, ConfigPageMetaDataSource, ConfigPageMetaDataSourceProvider}
import java.lang.{String}
/**
 * <p>
 * Created by IntelliJ IDEA.
 * User: zslajchrt
 * Date: Aug 15, 2010
 * Time: 4:55:26 PM
 */


object L10nStarter1 {
  val PAGE_TITLE = "Phase 1"
  val PAGE_DESCRIPTION = "Phase 1 Description"
  val PAGE_ICON = "http://iquality.org/icon1"
  val PARAMETER0_TITLE = "First Parameter"
  val PARAMETER0_DESCRIPTION = "First Parameter Description"
  val PARAMETER0_ICON = "http://iquality.org/icon2"
  val PARAMETER0_VALUE = "X"
  val PARAMETER0_VALUE_TITLE = "ValueX"
  val PARAMETER0_VALUE_DESCRIPTION = "ValueX Description"
  val PARAMETER0_VALUE_ICON = "http://iquality.org/icon3"
}

/**
 * There is also the L10nStarter1.properties file containing complementary meta-data to those specified by this starter.  
 */
class L10nStarter1 extends Starter[String] with HasHintsMetaDataSourceProvider {
  def newInstance() = phase1("xyz")

  def phase1(p1: String): String = {
    p1 + p1
  }

  def destroy(instance: String) = null

  // localization

  def configPageMetaDataSource(phaseMethod: String) = phaseMethod match {
    case "phase1" => {
      Some(new MyConfigPageMetaDataSource)
    }
    case _ => None
  }

  class MyConfigPageMetaDataSource extends HasHintsMetaDataSource {
    def configPageMetaData(loc: Locale) = {
      class MyConfigPageMetaData extends HasHintsMetaData {
        val pageLocale = loc
        val pageMeta = Some(new DefaultCommonMetaData(Some(L10nStarter1.PAGE_TITLE), Some("Phase 1 Description"), None))

        def propertyMeta[X](property: Property[X]) = property.name match {
          case "parameter0" => Some(new DefaultCommonMetaData(Some(L10nStarter1.PARAMETER0_TITLE),
            Some(L10nStarter1.PARAMETER0_DESCRIPTION), None))
          case _ => None
        }

        def propertyValueMeta[X](property: Property[X]) = None

        def hintMeta[H](hint: Property[H]) = None
      }

      Some(new MyConfigPageMetaData)
    }
  }

}





























